package com.jinzhi.jzweb.service.impl;

import com.jinzhi.common.base.CoreServiceImpl;
import com.jinzhi.common.utils.StringUtil;
import com.jinzhi.jzweb.dao.JzTrainCertificateDao;
import com.jinzhi.jzweb.domain.JzTrainCertificateDO;
import com.jinzhi.jzweb.service.JzTrainCertificateService;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author mengzhichao
 * @create 2022-09-23-16:39
 */
@Service
public class JzTrainCertificateServiceImpl extends CoreServiceImpl<JzTrainCertificateDao, JzTrainCertificateDO> implements JzTrainCertificateService {


    @Override
    public List<JzTrainCertificateDO> getUserCertificate(String certificateNumber, String idNumber, String name) {
        Map map =new HashMap();
        if (StringUtil.isNotNull(certificateNumber)){
            map.put("certificateNumber",certificateNumber);
        }
        if (StringUtil.isNotNull(idNumber)){
            map.put("idNumber",idNumber);
        }
        if (StringUtil.isNotNull(name)){
            map.put("name",name);
        }
        List<JzTrainCertificateDO> userCertificateList = baseMapper.getUserCertificate(map);
        if (userCertificateList != null) {
        for (int i=0;i<userCertificateList.size();i++) {
                userCertificateList.get(i).setSex("0".equals(userCertificateList.get(i).getSex()) ? "男" : "女");
                if ("1".equals(userCertificateList.get(i).getType())) {
                    userCertificateList.get(i).setType("岗位能力培训合格证书");
                }
                if (Double.valueOf(userCertificateList.get(i).getGrade()) > 60) {
                    userCertificateList.get(i).setGrade("合格");
                } else {
                    userCertificateList.get(i).setGrade("不合格");
                }
        }
        }
        return userCertificateList;
    }
}
